﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class administrator_Thong_tin_cong_ty : System.Web.UI.Page
{
    dulieuDataContext db=new dulieuDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            LoadThongTin();
        }

    }
    protected void LoadThongTin()
    {
        rpt_thong_tin.DataSource = from o in db.InfoCompanies where o.id == 1 select o;
        rpt_thong_tin.DataBind();
    }
    protected void UpdateMenu(object sender, ImageClickEventArgs e)
    {
        var info = (from o in db.InfoCompanies where o.id == 1 select o).SingleOrDefault();
        if (info != null)
        {
            info.Name = txttencongty.Text;
            info.Address = txtdiachi.Text;
            info.Mobile = txtdienthoai.Text;
            info.Fax = txtfax.Text;
            info.Email = txtemail.Text;
        }
        db.SubmitChanges();
        LoadThongTin();
        lblthongbao.Text = "Cập nhật thành công";
        System.Threading.Thread.Sleep(800);
    }
    protected void UpdateCheck(object s, RepeaterCommandEventArgs e)
    {
        if(e.CommandName=="edit")
        {
            var info = (from o in db.InfoCompanies where o.id == 1 select o).SingleOrDefault();
            if (info != null)
            {
                txttencongty.Text = info.Name;
                txtdiachi.Text = info.Address;
                txtdienthoai.Text = info.Mobile;
                txtemail.Text = info.Email;
                txtfax.Text = info.Fax;
            }
        }
    }

}